<template>
    <div>
        <Tabs v-model="tabName">
            <TabPane label="义务人信息" name="name1">
                <ss11005-tab1 :familyId="familyId" :familyInfo="familyInfo" :type="17" ref="tab1"
                              :disabledForStop="disabledForStop"/>
            </TabPane>
            <TabPane label="义务人家庭成员信息" name="name2">
                <ss11005-tab2 :familyId="familyId" :familyInfo="familyInfo" :type="17"
                              :disabledForStop="disabledForStop"/>
            </TabPane>
        </Tabs>
        <div style="height:40px;line-height:40px;margin-top:10px;text-align: center">
            <Button @click="prevStep">上一步</Button>
            <Button type="error" @click="calculate()" style="margin-left: 20px"
                    v-if="!disabledForStop&&tabName=='name1'">计算月赡(抚、扶)养费
            </Button>
            <Button type="primary" @click="nextStep()" :loading="btnLoading" style="margin-left:20px">下一步</Button>
        </div>
    </div>
</template>
<script>

    import Ss11005Tab1 from '../ss11_create_steps/tabs/Ss11005Tab1'
    import Ss11005Tab2 from '../ss11_create_steps/tabs/Ss11005Tab2'
    import {getAction, postAction} from '@/api/request';

    export default {
        components: {Ss11005Tab1, Ss11005Tab2},
        mixins: [],
        data() {
            return {
                familyInfo: this.$parent.familyInfo,
                familyId: this.$parent.familyInfo.ss17001Id,
                isSendedHd: this.$parent.familyInfo.isSendedHd,
                azdf0007: this.$parent.familyInfo.ssca0043?this.$parent.familyInfo.ssca0043:this.$parent.familyInfo.azdf0007,
                btnLoading: false,
                disabledForStop: false,
                tabName: 'name1'
            }
        },
        methods: {
            prevStep() {
                this.$emit('prevStep')
            },
            async nextStep() {
                this.btnLoading = true;
                var result = await this.check();
                if (result) {
                    this.$emit('nextStep');
                }
                this.btnLoading = false;
            },
            async check() {
                var check = true;
                var result = await postAction('/api/ac/subsistence/ss17005Service/updateAndCheckStep5',
                    {
                        azcp0500: this.familyId,
                        azdf0007: this.azdf0007,
                        ssca0002: this.familyInfo.ssca0002,
                        ss12001Id: this.$parent.familyInfo.ss12001Id
                    });
                if (result.data.errcode != 0) {
                    this.$Message.error(result.data.errmsg);
                    check = false;
                }
                return check;
            },
            async calculate() {
                this.$refs.tab1.loading = true;
                var result = await this.check();
                if (result) {
                    this.$refs.tab1.edit();
                } else {
                    this.$refs.tab1.loading = false;
                }
            }
        },
        mounted() {

        },
        created() {
            // this.familyInfo.azdf0007 = this.familyInfo.ssca0043;
            let that = this;
            //如是停救，operationType=300,则页面不可编辑
            if (that.$parent.familyInfo.ssca0016 == '300' || that.$parent.familyInfo.ssca0016 == '500' || that.$parent.familyInfo.ssca0016 == '501') {
                that.disabledForStop = true
            } else if (that.$parent.familyInfo.yjab0012 == '01' || that.$parent.familyInfo.yjab0012 == '02' || that.$parent.familyInfo.yjab0012 == '04') {
                //预警处置 已处置、维持现状、停救 不可编辑数据
                that.disabledForStop = true
            }
        },
    }
</script>
<style scoped>

</style>
